package com.itheima.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.Announcement;
import com.itheima.mapper.AnnounCementMapper;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class AnnounCementServiceimpl implements AnnounCementService {
    @Autowired
    private AnnounCementMapper announCementMapper;
    @Override
    public PageBeanVo findAll(Integer pageNum, Integer pageSize) {
        //开启分页
        Page<Announcement> page = new Page<>(pageNum, pageSize);
        //创建条件
        QueryWrapper<Announcement> qw = new QueryWrapper<>();
        qw.orderByDesc("updated");
        page= announCementMapper.selectPage(page,qw);

        return new PageBeanVo(pageNum,pageSize,page.getTotal(),page.getRecords());
    }
}
